package com.converters;

import com.domain.WriteData;
import com.enums.Alignment;
import com.enums.TextLevEnum;
import lombok.Data;

@Data
public class StringConverter implements Converter {

    /**
     * 数据转换
     * @param key
     * @param obj
     * @return
     */
    public WriteData convertToWriteData(String key, Object obj, Alignment alignment, TextLevEnum levEnum) {
        if (obj == null) {
            return new WriteData(key, "", alignment, levEnum);
        } else {
            return obj instanceof String ? new WriteData(key, (String)obj, alignment, levEnum) : new WriteData(key, String.valueOf(obj), alignment, levEnum);
        }
    }
}
